package com.cyy.snakebar;

import android.support.design.widget.Snackbar;
import android.view.View;

/**
 * Created by 999555yun on 2016/7/12.
 */
public class ColoredSnackbar {

    private static final int red = 0xfff44336;
    private static final int green = 0xff4caf50;
    private static final int blue = 0xff2195f3;
    private static final int orange = 0xffffc107;

    /**
     * 得到当前的SnackBar的布局View对象
     */
    private static View getSnackBarLayout(Snackbar snackbar){
        if(snackbar !=null){
           return snackbar.getView();
        }
        return null;
    }
    private static Snackbar colorSnackBar(Snackbar snackbar,int colorId){
        View snackBarView = getSnackBarLayout(snackbar);
        if(snackBarView != null){
            snackBarView.setBackgroundColor(colorId);
        }
        return snackbar;
    }
    public static Snackbar info(Snackbar snackbar){
        snackbar.setActionTextColor(orange);
        return colorSnackBar(snackbar,blue);
    }
    public static Snackbar warning(Snackbar snackbar){
        snackbar.setActionTextColor(blue);
        return colorSnackBar(snackbar,orange);
    }
    public static Snackbar alert(Snackbar snackbar){
        return colorSnackBar(snackbar,red);
    }
    public static Snackbar confirm(Snackbar snackbar){
        return colorSnackBar(snackbar,green);
    }
}
